package cn.jiyun.common.config;import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.RestClient;
import org.apache.http.HttpHost;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class ESClientUtil {
    private static RestHighLevelClient client;

    static {
        try {
            InetAddress address = InetAddress.getByName("127.0.0.1");
            client = new RestHighLevelClient(
                    RestClient.builder(new HttpHost(address.getHostAddress(), 9200, "http"))
            );
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

    public static RestHighLevelClient getClient() {
        return client;
    }
}
